package com.augurit.gzcgwsp.ljzyz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.augurit.gzcgwsp.ljzyz.convert.YwYnBustransferConvertor;
import com.augurit.gzcgwsp.ljzyz.dao.YwYnBustransferDao;
import com.augurit.gzcgwsp.ljzyz.entity.YwYnBustransfer;
import com.augurit.gzcgwsp.ljzyz.service.IYwYnBustransferService;
import com.augurit.gzcgwsp.ljzyz.web.form.YwYnBustransferForm;

@Service
@Transactional
public class YwYnBustransferImpl implements IYwYnBustransferService{
	@Autowired
	private YwYnBustransferDao ywYnBustransferDao;
	@Override
	public Page<YwYnBustransferForm> search(Page<YwYnBustransferForm> page,
			List<PropertyFilter> filters) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Page<YwYnBustransferForm> search(Page<YwYnBustransferForm> page,
			YwYnBustransferForm form) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void delete(Long... ids) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public YwYnBustransferForm get(Long id) {
		
		return null;
	}

	@Override
	public void save(YwYnBustransferForm... forms) {
		if(forms != null)
			for(YwYnBustransferForm form : forms)
				this.save(form);
		
	}
	
	
	/**
	 * 保存新增或修改的Form对象
	 */
	public void save(YwYnBustransferForm form){
		if(form != null){
			YwYnBustransfer entity = null;
			
			//准备VO对象
			if(form != null && form.getId() != null){
				entity = ywYnBustransferDao.get(form.getId());
			}else{
				entity = new YwYnBustransfer();
			}
			
			//属性值转换
			YwYnBustransferConvertor.convertFormToVo(form, entity);
			//保存
			ywYnBustransferDao.save(entity);
			//回填ID属性值
			form.setId(entity.getId());
		}
	}

	@Override
	public void saveEntity(YwYnBustransfer entity) {
		this.ywYnBustransferDao.save(entity);
	}

	@Override
	public YwYnBustransfer getEntity(Long busid, Long nssyid) {
		String sql=" from YwYnBustransfer where busId="+busid+" and nssyId="+nssyid;
		List<YwYnBustransfer> list=ywYnBustransferDao.find(sql);
		if(list.size()>0){
			return list.get(0);
		}
		return null;
	}

}
